<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>替换</title>
</head>
<body>
        <input type="text" id="mobile">
        <input type="button" value="点我" onclick="dosth()">
        <div id="out"></div>
        <script>
            var mobileobj=document.getElementById('mobile');
            var m=mobileobj.value;
            var s =m.substr(3,4);
            var r =m.replace(s,'****');
            var outobj = document.getElementById('out');
            outobj.innerHTML = r;
        </script>
</body>
</html>